import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import operate from '@dfeidao/atom-nodejs/db/operate';
import { systemid, productid } from '../../atom/config';
interface Message {
	_id: string,
	post_package_name: string,
	plan_cla_attr_name: string,
	plan_type_name: string,
}

// interface IWebResult {
// 	data: unknown;
// 	cookie?: {
// 		[name: string]: string;
// 	} | null;
// 	content_type?: string;
// 	headers?: {
// 		[key: string]: string[];
// 	};
// 	attachment?: string;
// 	redirect?: string;
// 	status_code?: number;
// }

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	const { exec, update } = operate(action_id, session_id, systemid);

	// 修改数据
	update('post_package', { productid, _id: message._id }, { post_package_name: message.post_package_name, plan_cla_attr_name: message.plan_cla_attr_name, plan_type_name: message.plan_type_name });
	const ret = await exec();
	return { ret }
}
